import allure
from appium.webdriver.common.appiumby import AppiumBy


from src.day42.PO.search_page import SearchPage
from src.day42.PO.selected_page import SelectedPage
from src.day42.PO.xueqiu import XueQiu


class MainPage(XueQiu):
    __SEARCH_NO_INPUT = AppiumBy.ID, 'com.xueqiu.android:id/home_search'
    __SELECTED=(AppiumBy.XPATH,'//*[@text="自选" and @resource-id="com.xueqiu.android:id/tab_name"]')
    __WHOLE=(AppiumBy.XPATH, '//*[@text="全部"]')
    def goto_search_page(self):
        with allure.step("点击搜索框，进入搜索页面"):
            self.find_and_click(*self.__SEARCH_NO_INPUT)
        return SearchPage(self.driver)

    def goto_selected_page(self):
        with allure.step("点击【自选】按钮"):
            self.find_and_click(*self.__SELECTED)
        with allure.step("点击全部按钮，进入全部自选页面"):
            self.find_and_click(*self.__WHOLE)
        return SelectedPage(self.driver)